package com.sh.healthtv.database;

import com.sh.healthtv.database.model.CollectionProgram;

import org.litepal.crud.DataSupport;

import java.util.List;

/**
 * Created by zhouyucheng on 2017/8/10.
 */

public class LitepalTVCollectUitils {

    public static boolean insertTVCollect(CollectionProgram program) {
        return program.save();
    }

    /**
     * 删除最后一个(根据id)
     */
    public static int deleteTVCollect(String useId) {
        return DataSupport.deleteAll(CollectionProgram.class, "useId = ? ", useId);
    }

    public static int updataTVCollect(CollectionProgram program, String useId) {
        return program.updateAll(" useId=? ", useId);
    }

    public static List<CollectionProgram> queryTVCollect(String useId) {
        return DataSupport.where("useId = ?", useId).find(CollectionProgram.class);
    }

    public static List<CollectionProgram> queryAllTVCollect() {
        return DataSupport.order("id desc").find(CollectionProgram.class);
    }
}
